# Patching coreboot+SeaBIOS+PXE+Linux for input over serial

Instructions here are specifically tailored to the KGPE-D16, but should work
for other boards with minor modifications, particularly to the PCI ID of the
Ethernet controller used when building and installing iPXE.

----

Get the base ROM (no need to recompile most of it, but you can if you want). Consider making a backup.

	# flashrom -p internal -r coreboot.rom

Enable the VGA<->serial console, sercon, in SeaBIOS. 1016 is the decimal
encoding of `0x3f8`, the port number for serial on traditional PC
architectures. 

	# ./cbfstool coreboot.rom add-int -i 1016 -n etc/sercon-port

Deduplicate duplicated character duplicates.

	# ./cbfstool coreboot.rom add-int -i 0 -n etc/screen-and-debug

----

Get IPXE source code:

	$ git clone git://git.ipxe.org/ipxe.git

Patching IPXE to output purely over serial, bypassing weird VGA emulation, as per https://pelican.craoc.fr/coreboot.html#ipxe

	diff --git a/src/config/console.h b/src/config/console.h
	index 9f770d09..1f181177 100644
	--- a/src/config/console.h
	+++ b/src/config/console.h
	@@ -22,9 +22,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
	  *
	  */
	 
	-//#undef       CONSOLE_PCBIOS          /* Default BIOS console */
	-//#undef       CONSOLE_EFI             /* Default EFI console */
	-//#undef       CONSOLE_LINUX           /* Default Linux console */
	+#undef CONSOLE_PCBIOS          /* Default BIOS console */
	+#undef CONSOLE_EFI             /* Default EFI console */
	+#undef CONSOLE_LINUX           /* Default Linux console */
	 
	 /*
	  * Additional console types
	@@ -34,7 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
	  *
	  */
	 
	-//#define      CONSOLE_SERIAL          /* Serial port console */
	+#define        CONSOLE_SERIAL          /* Serial port console */
	 //#define      CONSOLE_FRAMEBUFFER     /* Graphical framebuffer console */
	 //#define      CONSOLE_SYSLOG          /* Syslog console */
	 //#define      CONSOLE_SYSLOGS         /* Encrypted syslog console */

Build IPXE:

	$ make bin/808610d3.rom

------------------

Remove the existing IPXE rom and replace it with our patched one, 808610d3.rom. Name/build target corresponds to the vendor/device ID in PCI

	# cbfstool coreboot.rom remove -n pci8086,10d3.rom                    
	# cbfstool coreboot.rom add -f bin/808610d3.rom -n pci8086,10d3.rom -t raw

------------------

Flash it back:

	# flashrom -p internal -w coreboot.rom
